﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
using Tong.UpFile;//上传文件类
public partial class inc_UpFile : System.Web.UI.Page
{
    /// <summary>
    ///  上传文件路径 
    /// </summary>x
    string uppath;//上传文件路径

    /// <summary>
    ///  要显示路径的文本框名 
    /// </summary>
    string EditName;//要显示路径的文本框名
    /// <summary>
    ///  点击显示这个页面的前一个页面的表单名 
    /// </summary>
    string formName;//点击显示这个页面的前一个页面的表单名
    /// <summary>
    /// 数据库访问通用类 TextData 实例
    /// </summary>
    public TongUse TextData = new TongUse();
    protected void Page_Load(object sender, EventArgs e)
    {
        string upfileErr="";//上传文件错误信息
        
       try
       {
            uppath = Request.QueryString["uppath"].ToString();
            EditName = Request.QueryString["EditName"].ToString();
            formName = Request.QueryString["formName"].ToString();
            
            
           
            
           UpLoadFile UpFileClass = new UpLoadFile("rar,aspx,cs,zip,gif,jpg,jpeg,tif,ai,psd,doc,xls,html,cdr,dwd,dxf,fla,xml,swf,txt", 1024000, Server.MapPath(uppath+"/"  ));//建立上传文件类
            UpFileClass.UpLoad();//上传文件
           //upfileErr = UpFileClass.ErrorMessage.ToString();//出错信息

            if (upfileErr.Trim() == "" && upfileErr != null)//如果没有错误信息

            {  
                
                TextData.ResonseAlert("上传文件成功");
                string filevalue = UpFileClass.FileName;//生成文件名;
               
                //处理 小图片
                Tong.TongUse.SomePic(Server.MapPath(TongUse.SysPath + "aspnet/admin/inc/" + uppath + "/" + UpFileClass.FileName),
                    Server.MapPath(TongUse.SysPath + "aspnet/admin/inc/" + uppath + "/S" + UpFileClass.FileName),150, 150, "H");

                Response.Write("<script>window.opener." + formName + "." + EditName + ".value='" + TongUse.SysPath + "aspnet/admin/inc/" + uppath + "/" + filevalue + "';window.close();</script>");
            }
            else
            {
                info.Text = upfileErr;
                TextData.ResonseAlert("上传文件失败");
            }
       }
       catch (Exception ex)
        {
            Response.Write(UpFlie.Value.ToString() + "<br>");
       }
    }
}
